require.config({baseUrl: '/js/lib',urlArgs: "v0.0.1"});
require(['zepto', 'lib'], function($, lib) {
  var fn = {}, lib = new lib();
  $.extend(fn, {
    pageNo: 1,
    pageSize: 20,
    noMore: false,
    init: function(){
      
      this.balanceDetail();
      this.roll();
    },
    balanceDetail: function(){
      var _t = this;
      lib.onLoading();
      lib.ajx(lib.getReq().ser + 'sellerCenter/balanceDetail.action', {pageNo: _t.pageNo, pageSize: _t.pageSize}, function(data){
        if(data.infocode === '0'){
          if(data.info.balanceList.length < _t.pageSize) _t.noMore = true;
          var h = '';
          $.each(data.info.balanceList.reverse(), function(k, v){
            h += `<li>
                    <ul class="ui-accout-list ${v.balanceType === 2 ? 'ui-tixian' : 'ui-dingdan'}">
                      <li></li>
                      <li>
                        <p>${v.balanceType === 2 ? '支付宝提现' : '订单:' +　v.orderId}</p>
                        <p>${v.occureDate}</p>
                      </li>
                      <li>${v.balanceType === 2 ? '-' : '+'}${v.balance}</li>
                    </ul>
                  </li>`;
          });
          $(".ui-accout-detail").append(h);
        }else lib.showMessage(data.info);
      }, function(){
        lib.showMessage("网络延时，请稍后再试");
      });
    },
    roll: function(){
      var _t = this;
      $(window).scroll(function(){
        if(!_t.noMore &&　$(window).scrollTop() >= $(document).height() - $(window).height()){
          _t.pageNo ++ ;
          _t.balanceDetail();
        }
      });
    }
  });
  fn.init();
});